package com.sxj.corejava.code07_面向对象.多态;

import java.util.Scanner;

/**
 * @author 石小俊
 * @date 2025年01月07日
 */
public class Test02 {

    public static void main(String[] args) {
        System.out.println("***********************欢迎来到紫金宠物店***********************");
        showMenu();
    }

    public static void showMenu() {
        Scanner sc = new Scanner(System.in);
        System.out.print("请选择领养的宠物类型(1.狗狗 2.猫咪 3.猪猪 4.退出):");
        int choice = sc.nextInt();
        String name = null;
        String gender = null;
        Pet pet = null;
        switch (choice) {
            case 1:
                System.out.print("请为您领养的宠物取一个名字:");
                name = sc.next();
                System.out.print("请输入您领养的宠物性别:");
                gender = sc.next();
                System.out.print("请输入您领养的宠物狗年龄:");
                int age = sc.nextInt();
                pet = new Dog(name, gender, age);
                break;
            case 2:
                System.out.print("请为您领养的宠物取一个名字:");
                name = sc.next();
                System.out.print("请输入您领养的宠物性别:");
                gender = sc.next();
                System.out.print("请输入您领养的宠物猫的品种:");
                String type = sc.next();
                pet = new Cat(name, gender, type);
                break;
            case 3:
                System.out.print("请为您领养的宠物取一个名字:");
                name = sc.next();
                System.out.print("请输入您领养的宠物性别:");
                gender = sc.next();
                System.out.print("请输入您领养的宠物猪的爱好:");
                String hobby = sc.next();
                pet = new Pig(name, gender, hobby);
                break;
            case 4:
                System.out.println("提示:您已经退出!");
                break;
            default:
                System.out.println("错误:对不起,您输入的选项有误,请重新输入");
                showMenu();
                break;
        }
        pet.show();
    }

}
